import java.util.*;

public class ListSet {
    public static void main(String[] args) {
        // list 是有序的
        List<Integer> list = new ArrayList<>();
        list.add(null);
        list.add(null);
        list.add(1);
        list.add(2);
        System.out.println("list: "+ list.toString());
        //使用迭代器遍历
        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        System.out.println("-------------------------------------------------");

        //set是无序的
        Set<Integer> set = new HashSet<>();
        set.add(null);
        set.add(null);
        set.add(1);
        set.add(1);
        System.out.println(set.toString());

        //使用迭代器遍历
        Iterator<Integer> iteratorSet = set.iterator();
        while (iteratorSet.hasNext()){
            System.out.println(iteratorSet.next());
        }
    }
}
